package org.example;/*
 * title:
 * author:
 * date:
 * description:
 * */

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class FutureAPI {
    public static void main(String[] args) throws ExecutionException, InterruptedException, TimeoutException {
        FutureTask futrueTask1 = new FutureTask(() -> {
            TimeUnit.SECONDS.sleep(5);
            return "task1 over";
        });

        Thread thread = new Thread(futrueTask1, "t1");

        thread.start();

        System.out.println("我去忙其他的吧");

        System.out.println(futrueTask1.get(3,TimeUnit.SECONDS));
    }
}
